class Bus {
    constructor(){
        this.events=this.events|| new Map()
    }
    on(type,callback){
        if(!this.events.get(type)){
            //如果容器里面没有这种类型的事件，就增加
            this.events.set(type,callback)
        }
    }
    off(type){
        if(this.events.get(type)){
            this.events.delete(type)
        }
    }
    emit(type){
        let fn = this.events.get(type)
        if(fn){
            fn.apply(this,[...arguments].slice(1))
        }
        
    }
}
let bus=new Bus()
export {bus}